/*
 * Copyright (C) 2001-2008  Nishanth Menon <menon.nishanth at gmail dot com>
 *
 * Part of the predict two project done during NITC Final year.
 * Predict2: http://code.google.com/p/predict2/
 * NITC: http://web.nitc.ac.in/~cse/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US
 */


/*
 * yes_no.java
 *
 * Creat2ed on September 14, 2001, 6:06 AM
 */
package GUI;

/**
 * The <I>Yes_no</I> class is meant to be a Class independent of all and should
 * Create a result 1 = yes
 *               0=no
 * @author lazarus
 * @version 1.01
 */
public class yes_no extends java.awt.Dialog
{

   /** Creates new form yes_no
    * @param parent the parent
    * @param modal the modal or not boolean
    * @param Message the Message that is to displayed
    */
    public yes_no (java.awt.Frame parent, boolean modal, String Message)
    {
        super (parent, modal);
        this.Message = Message;
        initComponents ();
        pack ();
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the FormEditor.
     */
    private void initComponents ()
    {
        setResizable (true);
        MainPanel = new java.awt.Panel ();
        theMessage = new javax.swing.JLabel ();
        YesButton = new javax.swing.JButton ();
        NoButton = new javax.swing.JButton ();
        // drawImagePanel = new java.awt.Panel ();
        drawImagePanel = new FlamePanel ();
        setLayout (new javax.swing.BoxLayout (this, 0));
        setBackground (java.awt.Color.black);
        addWindowListener (new java.awt.event.WindowAdapter ()
                           {
                           public void windowClosing (java.awt.event.WindowEvent evt)
                           {
                           closeDialog (evt);}
                           }
        );

        MainPanel.setLayout (null);
        MainPanel.setFont (new java.awt.Font ("Dialog", 0, 11));
        MainPanel.setName ("Drawing Panel");
        MainPanel.setBackground (java.awt.Color.black);
        MainPanel.setForeground (java.awt.Color.black);

        theMessage.setText ((Message == null) ? "There is No Message" : Message);
        theMessage.setToolTipText ((Message == null) ? "What tool tip Do U expect?" : Message);
        theMessage.setForeground (java.awt.Color.orange);
        int FS = 10;

        if (Message != null)
          {
              if (Message.length () > 45)
                  FS = 8;
              if (Message.length () < 34)
                  FS = 15;
              if (Message.length () < 26)
                  FS = 20;
              if (Message.length () < 20)
                  FS = 30;
          }
        theMessage.setFont (new java.awt.Font ("Arial", 1, FS));
        MainPanel.add (theMessage);
        theMessage.setBounds (50, 130, 320, 40);


        YesButton.setIcon (new javax.swing.ImageIcon ("images/yes.jpg"));
        YesButton.setToolTipText ("Press this to Say Yes");
        YesButton.setBorder (null);
        YesButton.setActionCommand ("YesButton");
        YesButton.setText ("Yes");
        YesButton.setBackground (java.awt.Color.black);
        YesButton.addMouseListener (new java.awt.event.MouseAdapter ()
                                    {
                                    public void mouseClicked (java.awt.event.MouseEvent evt)
                                    {
                                    YesButtonMouseClicked (evt);}
                                    }
        );
        MainPanel.add (YesButton);
        YesButton.setBounds (60, 210, 90, 60);


        NoButton.setIcon (new javax.swing.ImageIcon ("images/no.jpg"));
        NoButton.setToolTipText ("Press this to Say No");
        NoButton.setLabel ("No");
        NoButton.setBorder (null);
        NoButton.setName ("noButton");
        NoButton.setActionCommand ("NoButton");
        NoButton.setText ("No");
        NoButton.setBackground (java.awt.Color.black);
        NoButton.addMouseListener (new java.awt.event.MouseAdapter ()
                                   {
                                   public void mouseClicked (java.awt.event.MouseEvent evt)
                                   {
                                   NoButtonMouseClicked (evt);}
                                   }
        );
        MainPanel.add (NoButton);
        NoButton.setBounds (290, 220, 90, 50);


        drawImagePanel.setFont (new java.awt.Font ("Dialog", 0, 11));
        drawImagePanel.setName ("theDrawImagePanel");
        drawImagePanel.setBackground (java.awt.Color.black);
        drawImagePanel.setForeground (java.awt.Color.black);
        MainPanel.add (drawImagePanel);
        // sona = new F1 (drawImagePanel);
        drawImagePanel.setBounds (110, 20, 190, 90);


        add (MainPanel);

    }

    private void NoButtonMouseClicked (java.awt.event.MouseEvent evt)
    {
        // Add your handling code here:
        Result = false;
        dispose ();
    }

    private void YesButtonMouseClicked (java.awt.event.MouseEvent evt)
    {
        // Add your handling code here:
        Result = true;
        dispose ();
    }

    /** Closes the dialog */
    private void closeDialog (java.awt.event.WindowEvent evt)
    {
        setVisible (false);
        dispose ();
    }
    public boolean getResult ()
    {
        return Result;
    }
    public static void Sta ()
    {
        String k = "";

        if (Message != null)
          {
              for (int i = 0; i < Message.length (); i++)
                {
                    // System.out.println ("i=" + i + "K=" + k + " Message=" +
                    // Message);
                    String m = Message.substring (i, i + 1);

                    m = (m.equals (" ")) ? "+" : m;
                    k = k.concat (m);
                }
              drawImagePanel.setMessage (k);
          }
        drawImagePanel.start ();
    }
    public static void Ba ()
    {
        drawImagePanel.stop ();
    }



    // Variables declaration - do not modify
    private java.awt.Panel MainPanel;
    private javax.swing.JLabel theMessage;
    private javax.swing.JButton YesButton;
    private javax.swing.JButton NoButton;

    // private java.awt.Panel drawImagePanel;
    private static FlamePanel drawImagePanel;
    private static String Message;
    private boolean Result;
    private static FlamePanel sona;

    // End of variables declaration

}
